package com.bw.module_service.adapter

import android.graphics.Color
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView
import androidx.recyclerview.widget.RecyclerView.Recycler
import com.bw.module_service.R
import com.bw.module_service.model.SignStatusTab


class SignStatusTabAdapter (
    private val tabsList:List<SignStatusTab>,
    private var selectedPosition: Int,
    private val onTabSelected: (Int) -> Unit
    ):RecyclerView.Adapter<SignStatusTabAdapter.TabViewHolder>() {


    fun updateSelectedPosition(position: Int) {
        selectedPosition = position
        notifyDataSetChanged()
    }


    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): TabViewHolder {
        val view = LayoutInflater.from(parent.context).inflate(R.layout.item_sign_status_tab,parent,false)
        return TabViewHolder(view)


    }

    override fun getItemCount(): Int {
        return tabsList.size
    }

    override fun onBindViewHolder(holder: TabViewHolder, position: Int) {
        val tab = tabsList[position]
        holder.tvTabText.text = tab.text


//        if (position == selectedPosition) {
//            holder.tvTabText.setBackgroundResource(R.drawable.select_tab)
//            holder.tvTabText.setTextColor(Color.WHITE)
//        } else {
//            holder.tvTabText.setBackgroundResource(R.drawable.selector_tab)
//            holder.tvTabText.setTextColor(Color.BLACK)
//        }
//
//        holder.itemView.setOnClickListener {
//            onTabSelected(position)
//        }



    }


    class TabViewHolder(itemView:View):RecyclerView.ViewHolder(itemView){
        val tvTabText: TextView = itemView.findViewById(R.id.tv1)
    }
}